package io.renren.modules.mvs.dao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.modules.mvs.dto.TicketDto;
import io.renren.modules.mvs.entity.TicketEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 罚单表
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2025-03-30 17:08:24
 */
@Mapper
public interface MvsTicketDao extends BaseMapper<TicketEntity> {

    IPage<TicketDto> selectPageByCondition(Page<Object> page, @Param("condition") Map<String, Object> condition);

    @Select("SELECT t1.id, t1.fine_amount, t1.overdue_fee, t1.wait_overdue_fee, t2.violation_time, t2.violation_deadline FROM mvs_ticket t1 " +
            "LEFT JOIN mvs_violation t2 ON t1.violation_id = t2.id")
    List<TicketDto> selectTicketDtoList();

    @Select("SELECT * FROM mvs_ticket WHERE id = #{id} AND (wait_fine > 0 OR wait_overdue_fee > 0)")
    TicketEntity selectByWaitPayment(@Param("id") String id);

    List<TicketEntity> selectWaitPaymentList(@Param("userId") Long userId);

    List<Map<String,?>> selectFineByDateRange(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("userId") Long userId);

    List<Map<String,?>> selectMoneyByDateRange(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("userId") Long userId);

    List<TicketDto> selectListByViolationIds(@Param("violationIds") List<Long> violationIds);
}
